package com.zzyl.controller.expirationtask;

import com.zzyl.service.CustomerReservationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

@Component
public class ReservationExpirationTask {

    @Autowired
    private CustomerReservationService customerReservationService;

    // 每小时的1分钟和31分钟执行一次
    @Scheduled(cron = "0 1,31 * * * ?")
    public void checkAndExpireReservations() {
        // 调用服务层方法检查并更新过期的预约
        customerReservationService.expireOutdatedReservations();
    }
}